package com.bawei.yangzongcai___day2.MaiDongFangQi.day2;

import okhttp3.OkHttpClient;
import okhttp3.logging.HttpLoggingInterceptor;
import retrofit2.Retrofit;
import retrofit2.adapter.rxjava2.RxJava2CallAdapterFactory;
import retrofit2.converter.gson.GsonConverterFactory;

/**
 * create by ertu
 * create on 2021/7/30
 * description
 */
public class Okhttpappture {

    public  static  Okhttpappture okhttpappture;

    public static Okhttpappture getOkhttpappture()
    {
        if (okhttpappture==null)
        {
            okhttpappture = new Okhttpappture();
        }
        return okhttpappture;
    }


    public Retrofit retrofits(String nur)
    {
        return new Retrofit.Builder()
                .baseUrl(nur)
                .client(new OkHttpClient.Builder()
                        .addInterceptor(new HttpLoggingInterceptor().setLevel(HttpLoggingInterceptor.Level.BODY))
                           .build())
                .addConverterFactory(GsonConverterFactory.create())
                .addCallAdapterFactory(RxJava2CallAdapterFactory.create())
                .build();
    }
}
